#ifndef KBestParseForest3O_H
#define KBestParseForest3O_H
#include"KBestParseForest3OGSibling.h"

class KBestParseForest3O : public KBestParseForest3OGSibling{
protected:
	int getKey(int dir, int k);

	virtual int getKey(int g, int s, int t, int dir, int comp, int k);

	ParseForestItem *****d_chart;

	void getIndex(int g, int s, int m, int t, int *m_index, int *t_index);

	virtual int getI_d(int i, int j, int k);

	virtual vector<pair<FeatureVector*, string*> >* getBestParses_strict(DependencyInstance *inst, DependencyPipe *pipe, 
		vector<vector<vector<double> > > &probs, vector<vector<vector<double> > > &probs_trips,
		vector<vector<vector<double> > > &probs_sibs, vector<vector<vector<vector<double> > > > &probs_ttrips,
		vector<vector<vector<vector<double> > > > &probs_tsibs,
		vector<vector<vector<vector<double> > > > &nt_probs, bool labeled);

	virtual vector<pair<FeatureVector*, string*> >* getBestParses_normal(DependencyInstance *inst, DependencyPipe *pipe, 
		vector<vector<vector<double> > > &probs, vector<vector<vector<double> > > &probs_trips, vector<vector<vector<double> > > &probs_sibs,
		vector<vector<vector<vector<double> > > > &probs_ttrips, vector<vector<vector<vector<double> > > > &probs_tsibs,
		vector<vector<vector<vector<double> > > > &nt_probs, bool labeled);

public:
	KBestParseForest3O(ParseForestItem *****d_chart, int start, int end, DependencyInstance &inst, int K);
	
	virtual ~KBestParseForest3O();
	
	bool add_d(int g, int s, int m, int t, int type, int dir, double score, ParseForestItem* p1, ParseForestItem* p2);

	bool add_output_d(ParseForestItem *output_d, int m, int t, int type, double score, ParseForestItem *p1, ParseForestItem *p2);
	
	double getProb_d(int g, int s, int m, int t, int dir);
	
	double getProb_d(int g, int s, int m, int t, int dir, int i);
	
	ParseForestItem* getItems_d(int g, int s, int m, int t, int dir);

	virtual vector<pair<FeatureVector*, string*> >* getBestParses(DependencyInstance *inst, DependencyPipe *pipe, 
		vector<vector<vector<double> > > &probs, vector<vector<vector<double> > > &probs_trips,
		vector<vector<vector<double> > > &probs_sibs, vector<vector<vector<vector<double> > > > &probs_ttrips,
		vector<vector<vector<vector<double> > > > &probs_tsibs,
		vector<vector<vector<vector<double> > > > &nt_probs, bool labeled, bool normal);

	virtual string* getDepString(ParseForestItem &pfi);
};
#endif
